package com.base.mapper;

import com.base.entity.CheckInRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.base.entity.Guest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 作者
 * @since 2024-11-30
 */
@Mapper
public interface CheckInRecordMapper extends BaseMapper<CheckInRecord> {

    @Select({
            "<script>",
            "SELECT * FROM check_in_record cir ",
            "LEFT JOIN guest g ON cir.guest_id = g.id ",
            "WHERE 1=1",  // 默认条件
            "<if test='name != null and name != \"\"'>",
            "AND g.name = #{name}",
            "</if>",
            "<if test='idCard != null and idCard != \"\"'>",
            "AND g.id_card = #{idCard}",
            "</if>",
            "</script>"
    })
    List<CheckInRecord> search(Guest guest);
}
